var express = require('express');
var router = express.Router();
var request = require('request');
var itemDao = require('../dao/itemDao');
var userAgentUtil = require('../utils/userAgent');


router.get('/', function(req, res, next) {
  var param = req.query || req.params;
  itemDao.query(param, function(result){
   if(userAgentUtil.isM(req)){
     res.render('m/index',{result:result});
   }
   else
    res.render('m/index',{result:result});
});

});

router.post('/', function (req, res) {
  var param = req.body;
  itemDao.query(param, function(result){

    res.send(result);
  });
});

module.exports = router;
